<template>
  <div class="home">
    <Nav :cut="'home'"></Nav>
    <template v-if="showServerAgreement">
      <UserServerAgreement :_parentThis="this"></UserServerAgreement>
    </template>
    <template v-else>
      <Banner></Banner>
      <Goods :goodsData="goodsData"></Goods>
      <DingTou :_parentThis="this" :dingtouData="dingtouData"></DingTou>
      <JinShengJin :jinshengjinData="jinshengjinData"></JinShengJin>
    </template>
    <div class="overlayer" @touchmove.stop :class="{'show':showServerAgreement}">
    </div>
    <Notify :parentThis='this'></Notify>
  </div>
</template>

<script>
  import Nav from 'components/Nav'
  import UserServerAgreement from 'components/UserServerAgreement'
  import Goods from 'components/home/Goods'
  import Banner from 'components/Banner'
  import DingTou from 'components/home/DingTou'
  import JinShengJin from 'components/home/JinShengJin'
  import API from './api'
  import Notify from './components/Notify'
  export default {
    name: 'home',
    components: {
      Nav,
      Banner,
      UserServerAgreement,
      Goods,
      DingTou,
      JinShengJin,
      Notify
    },
    data: function () {
      return {
        showServerAgreement: false,
        serverIsTrue: false,
        goodsData: [],
        dingtouData: '',
        jinshengjinData: [],
        notifyStatus: 2,
        dtTit: ''
      }
    },
    methods: {
      findOnePage: function () {
        this.$http.post(API.findOnePage, {
          id: ''
        }).then((ret) => {
          const result = ret.body
          if (result.code === 1) {
            this.goodsData = result.object.gs
          } else {
            this.notifyStatus = '0|' + result.message
          }
        }, (err) => {
          console.log(err)
        })
      },
      findRegularPutin: function () {
        var id = this.$cookie.get('id')
        this.$http.post(API.findRegularPutin, {
          userId: id
        }).then((ret) => {
          const result = ret.body
          if (result.code === 1) {
            this.dingtouData = result.object
          } else {
            this.notifyStatus = '0|' + result.message
          }
        }, (err) => {
          console.log(err)
        })
      },
      findKinsonGoldList: function () {
        this.$http.post(API.findKinsonGoldList, {
          pageSize: 100
        }).then((ret) => {
          const result = ret.body
          if (result.code === 1) {
            this.jinshengjinData = result.object.content
          } else {
            this.password = ''
            this.notifyStatus = '0|' + result.message
          }
        }, (err) => {
          this.password = ''
          console.log(err)
        })
      }
    },
    mounted: function () {
      this.findOnePage()
      this.findRegularPutin()
      this.findKinsonGoldList()
      if (this._parentThis) {
        this._parentThis.isHide = true
      }
    }
  }
</script>

<style>
  .home {
    min-width: 990px;
    background: #e9e9e9;
  }
</style>
